<template>
	<view class="wanl-page wanlshop-container wanl-list wanl-order-list">
	哈哈哈
		<!-- 医生详情弹窗 -->
		<u-popup v-model="showDesc" mode="bottom" height="600rpx" borderRadius="20rpx">
			<view class="content">
				<view class="top">
					<image :src="$wanlshop.oss('/uploads/staticImage/images/medical/peihu/bg.png')" mode="center"></image>
					
					<text>医生简介</text>
				</view>
				<view class="padding-sm"><rich-text :nodes="doctor.content"></rich-text></view>
			</view>
		</u-popup>
		<!-- 医生介绍面板 -->
		<view class="user padding-top-xs">
			<view class="header bg-white">
				<view class="imUserStatus">
					<image :src="$wanlshop.oss(doctor.image)" mode="aspectFill"></image>
					<text :class="{c:doctor.imUserStatus == 1}">{{doctor.imUserStatus_txt}}</text>
				</view>
				<view class="info">
					<view class="">
						<text>{{doctor.name}}</text>
						<text>{{doctor.doctor_level_text}}</text>
					</view>
					<view class="">
						<text> {{doctor.section_ids_text}} </text>
						<text>推荐指数</text>
						<uni-rate readonly :allowHalf="true" :max="5" :value="doctor.exponent" :size="12"
							color="#CCCCCC" active-color="#4CBD66" />
					</view>
				</view>
			</view>
			<view class="tag flex justify-start align-center">
				<view class="flex justify-start align-center" :class="{cur:doctor.isCollect == 1}" @tap="follow">
					<text class="iconfont icon-shoucangguanzhu" v-if="doctor.isCollect == 2"></text>
					<text class="wlIcon-31xuanze" v-if="doctor.isCollect == 1"></text>
					<text style="margin-left: 4rpx;">关注</text>
				</view>
				<!-- <text class="margin-left-xs">设置有号提醒</text> -->
			</view>
			<view class="bg-white padding-lr">
				<text class="t" v-for="(data,k) in doctor.feature_text" :key="k">{{data.name}}</text>
			</view>
			<view class="tab flex justify-between bg-white padding-lr padding-bottom">
				<view class="left">
					<text class="cur">专业擅长</text>
					<view>
						<block v-for="(data,k) in doctor.diease_ids_text" :key="k">
							{{data.name}}{{k+1 < doctor.diease_ids_text.length ? '、' : ''}}
						</block>
					</view>
				</view>
				<view class="right" @tap="showDesc = true">
					<text>查看简介</text>
					<text class="wlIcon-fanhui2"></text>
				</view>
			</view>
		</view>
		<!-- 队列提示 -->
		<view class="queue padding-top-xs u-padding-20">
			<view>医生正在接诊其他病人,请耐心排队</view>
			<view>您当前排在<text class="u-font-40">5</text>位</view>
			<view>请勿离开本页面，否则将重新开始排队</view>
			
			
		</view>
		<view class="container">
			<input type="text" v-model="inputID"
				:placeholder=" isLogin ? 'please enter a caller userID' : 'please enter your login userID' " />
			<text v-show="isLogin"> your userID: {{ userID }} </text>
			<button v-show="!isLogin" @click="handleLogin"> Login </button>
			<button v-show="isLogin" @click="handleCall"> start call </button>
		</view>
	</view>
</template>
<script>
	const TUICallKit = uni.requireNativePlugin('TencentCloud-TUICallKit'); //【1】import TUICallKit plugin
	uni.$TUICallKit = TUICallKit;
	import {
		genTestUserSig
	} from '@/debug/GenerateTestUserSig.js';
	import {
		mapState,
		mapActions
	} from 'vuex';
	export default {
		data() {
			return {
				inputID: '',
				isLogin: false,
				userID: '111',
				doctor: null,//医生信息
				showDesc: false,//医生简介显示、隐藏
			}
		},
		computed: {
			...mapState(['common'])
		},
		onLoad(options) {
			this.loadData(options.id)
			this.handleLogin()
		},
		methods: {
			//获取医生数据
			async loadData(id) {
				await uni.request({
					url: '/addons/internethospital/api.doctor/detail',
					method: 'POST',
					data: {
						id: id,
					},
					success: res => {
						this.doctor = res.data;
						// uni.setNavigationBarTitle({
						// 	title: `${res.data.name}医师`
						// })
					}
				});
			},
			// 关注 & 取消
			async follow() {
				await uni.request({
					url: '/addons/internethospital/api.collect/add',
					method: 'POST',
					data: {
						type:2,
						object_id: this.doctor.id
					},
					success: res => {
						this.doctor.isCollect = this.doctor.isCollect == 1 ? 2 : 1;
						this.$wanlshop.msg(`${this.doctor.isCollect == 1 ? '关注成功' : '取消关注'}`)
					}
				});
			},
			handleLogin() {
				this.userID = this.inputID;
				const {
					userSig,
					sdkAppID: SDKAppID
				} = genTestUserSig(this.userID);
				const loginParams = {
					SDKAppID,
					userID: this.userID,
					userSig
				}; // apply SDKAppID、userSig
				//【2】Login
				uni.$TUICallKit.login(loginParams, res => {
					if (res.code === 0) {
						this.isLogin = true;
						this.inputID = '';
						console.log('[TUICallKit] login success.');
					} else {
						console.error('[TUICallKit] login failed, failed message = ', res.msg, params);
					}
				});
			},
			handleCall() {
				try {
					const callParams = {
						userIDList: [this.inputID],
						callMediaType: 2, // 1 -- audio call，2 -- video call
						callParams: {
							roomID: 234,
							strRoomID: '2323423',
							timeout: 30
						},
					};
					//【3】start 1v1 video call
					uni.$TUICallKit.calls(callParams, res => {
						console.log('[TUICallKit] call params: ', JSON.stringify(res));
					});
					this.inputID = '';
				} catch (error) {
					console.log('[TUICallKit] call error: ', error);
				}
			}
		}
	}
</script>
<style lang="scss">
	page {
		background-color: #ededed;
	}
	.container {
		height: 100vh;
		display: flex;
		flex-wrap: wrap;
		flex-direction: column;
		align-items: center;
		margin: 30px;
	}
	.container input {
		height: 50px;
		border: 1px solid;
	}
	
	.container button {
		margin-top: 30px;
	}
	.user {
		position: relative;
	
		.header {
			padding: 16rpx 30rpx 10rpx 28rpx;
			display: flex;
			justify-content: flex-start;
			align-items: center;
	
			image {
				width: 120rpx;
				height: 120rpx;
				border-radius: 50%;
			}
	
			.info {
				>view {
					&:nth-child(1) {
						text {
							&:nth-child(1) {
								font-family: PingFang SC-Bold, PingFang SC;
								font-size: 34rpx;
								font-weight: bold;
								color: #333333;
								line-height: 48rpx;
							}
	
							&:nth-child(2) {
								font-size: 28rpx;
								font-family: PingFang SC-Medium, PingFang SC;
								font-weight: 500;
								color: #666666;
								line-height: 40rpx;
								margin-left: 12rpx;
							}
						}
					}
	
					&:nth-child(2) {
						display: flex;
						justify-content: flex-start;
						align-items: center;
	
						text {
							&:nth-child(1) {
								font-size: 28rpx;
								font-family: PingFang SC-Medium, PingFang SC;
								font-weight: 500;
								color: #666666;
								line-height: 40rpx;
								margin-right: 28rpx;
							}
	
							&:nth-child(2) {
								font-size: 28rpx;
								font-family: PingFang SC-Heavy, PingFang SC;
								font-weight: 800;
								color: #4CBD66;
								line-height: 40rpx;
								margin-right: 14rpx;
							}
						}
					}
				}
			}
		}
	
		.tag {
			position: absolute;
			top: 30rpx;
			right: 30rpx;
			font-size: 22rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #4CBD66;
			line-height: 26rpx;
	
			view {
				background: #E9F4EB;
				border-radius: 10rpx;
				padding: 6rpx 10rpx;
				&.cur {
					background-color: #ccc;
					color: #666;
				}
				text {
					&:nth-child(1) {
						font-size: 26rpx;
					}
				}
			}
	
			>text {
				display: inline-block;
				background: #E9F4EB;
				border-radius: 10rpx;
				padding: 6rpx 10rpx;
			}
		}
	
		.tab {
			.left {
				width: calc(100% - 200rpx);
	
				view,
				text {
					display: inline-block;
					font-size: 26rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #777777;
					line-height: 36rpx;
					margin-right: 20rpx;
	
					&:last-child {
						margin-right: 0;
					}
	
					&.cur {
						font-weight: 800;
						color: #4CBD66;
					}
				}
			}
	
			.right {
				width: 130rpx;
	
				text {
					color: #4CBD66;
	
					&:nth-child(1) {
						font-size: 26rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #4CBD66;
						line-height: 36rpx;
					}
	
					&:nth-child(2) {
						font-weight: bold;
						font-size: 24rpx;
					}
				}
			}
		}
	
		.t {
			display: inline-block;
			font-size: 20rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #FF2F2F;
			line-height: 30rpx;
			// width: 84rpx;
			height: 32rpx;
			border-radius: 24rpx;
			border: 1rpx solid #FF2F2F;
			text-align: center;
			margin: 16rpx 10rpx 10rpx 0;
			padding: 0 16rpx;
		}
	}
	
	
	
	
	
	.doctor {
		>.item {
			width: 690rpx;
			// height: 350rpx;
			background: #FFFFFF;
			border-radius: 10rpx;
			margin: 0 auto;
			margin-bottom: 20rpx;
			padding: 16rpx 14rpx;
	
	
			&:last-child {
				margin-bottom: 0;
			}
	
			.top {
				display: flex;
				justify-content: flex-start;
				align-items: center;
	
				image {
					width: 110rpx;
					height: 110rpx;
					margin-right: 28rpx;
					border-radius: 50rpx;
				}
	
				.info {
					text {
						display: inline-block;
					}
	
					>view {
						&:nth-child(2) {
							height: 36rpx;
							font-size: 26rpx;
							font-family: PingFang SC-Medium, PingFang SC;
							font-weight: 500;
							color: #555555;
							line-height: 36rpx;
						}
	
						text {
							&:nth-child(1) {
								font-size: 32rpx;
								font-family: PingFang SC-Bold, PingFang SC;
								font-weight: bold;
								color: #333333;
								line-height: 44rpx;
							}
	
							&:nth-child(2) {
								font-size: 26rpx;
								font-family: PingFang SC-Medium, PingFang SC;
								font-weight: 500;
								color: #666666;
								line-height: 36rpx;
								margin-left: 18rpx;
							}
						}
					}
				}
			}
	
			.tag {
				margin: 22rpx 0;
	
				text {
					display: inline-block;
					height: 40rpx;
					line-height: 38rpx;
					border-radius: 22rpx;
					padding: 0 16rpx;
					opacity: 1;
					font-size: 20rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					margin-right: 10rpx;
					box-sizing: border-box;
					border: 2rpx solid #4CBD66;
					color: #4CBD66;
	
					&:last-child {
						margin-right: 0;
					}
	
					&:nth-child(1) {
						border: 2rpx solid #FF2F2F;
						color: #FF2F2F;
					}
				}
			}
	
			.end {
				display: flex;
				justify-content: space-between;
				align-items: center;
				width: 658rpx;
				height: 120rpx;
				background: #F0FEF3;
				border-radius: 10rpx;
				padding: 0 12rpx;
	
				>text {
					font-size: 16rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #888888;
					line-height: 22rpx;
					margin-bottom: 30rpx;
				}
	
				>view {
					display: flex;
					justify-content: flex-start;
	
					>text {
						&:nth-child(1) {
							display: inline-block;
							width: 46rpx;
							height: 24rpx;
							background: #4CBD66;
							border-radius: 6rpx;
							line-height: 24rpx;
							text-align: center;
							font-size: 16rpx;
							font-family: PingFang SC-Medium, PingFang SC;
							font-weight: 500;
							color: #FFFFFF;
							margin-top: 10rpx;
						}
					}
	
					>view {
						margin-left: 16rpx;
						display: flex;
						flex-direction: column;
	
						view {
							&:nth-child(2) {
								display: inline-block;
								width: 584rpx;
								height: 40rpx;
								font-size: 28rpx;
								font-family: PingFang SC-Medium, PingFang SC;
								font-weight: 500;
								color: #666666;
								line-height: 40rpx;
								margin-top: 4rpx;
							}
	
							text {
								&:nth-child(1) {
									width: 508rpx;
									height: 48rpx;
									font-size: 34rpx;
									font-family: PingFang SC-Bold, PingFang SC;
									font-weight: bold;
									color: #333333;
									line-height: 48rpx;
								}
	
								&:nth-child(2) {
									color: #888888;
									font-size: 18rpx;
									padding-right: 20rpx;
								}
							}
						}
					}
				}
			}
		}
	}
	
	
	
	
	
	
	.content {
		height: 600rpx;
		position: relative;
	
		.top {
			position: relative;
			width: 750rpx;
	
			image {
				position: absolute;
				width: 100%;
				height: 80rpx;
			}
	
			text {
				display: inline-block;
				width: 100%;
				text-align: center;
				line-height: 80rpx;
				font-weight: bold;
			}
		}
	}
	
	
	
	.queue{
		view{
			text-align: center;
			color: $u-type-info-dark;
			text{
				color: $u-type-error-dark;
			}
		}
	}

	
</style>